package com.yuanxiao.common.api.feign.fallback;

import cn.hutool.json.JSONUtil;
import com.yuanxiao.common.api.entity.SysLogEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import com.yuanxiao.common.core.result.R;
import com.yuanxiao.common.core.result.ResultCode;
import com.yuanxiao.common.api.feign.SysServerFeignClient;

@Component
@Slf4j
public class SysServerFeignFallbackClient implements SysServerFeignClient {

    @Override
    public R saveLog(@RequestBody SysLogEntity logEntity) {
        log.info (JSONUtil.toJsonStr (logEntity));
        log.error("feign远程调用日志服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getUserByUserId(Long userId) {
        log.error("feign远程调用系统用户服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getUserByUserId(Long userId, String serverRequest) {
        log.error("feign远程调用系统用户服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R checkHandlepwd(Long userId, String handlePwd) {
        log.error("feign远程调用系统用户服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    @Override
    public R getDeptById(Long deptId) {
        log.error("feign远程调用系统部门服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }

    public R handelFeignCallList(String serverCode,String usedType,String bizCode){
        log.error("feign远程调用feign配置系统服务异常后的降级方法");
        return R.failed(ResultCode.DEGRADATION);
    }
}
